import pymysql.cursors
class database_mysql(object):
    def __init__(self,db_local):
        print("初始化")
        self.db_conn  = pymysql.connect(**db_local)
        self.db_cursor = self.db_conn.cursor()

    def get_row(self, sql, data = None):
        self.db_cursor.execute(sql)
        self.resultset = self.db_cursor.fetchall()
        self.db_cursor.close()
        return self.resultset

    def save_row(self, sql):
        self.db_cursor.execute(sql)
        self.db_conn.commit()
        self.db_cursor.close()

    db_config = {
    'host':"127.0.0.1", # database host

    'port': 3306, # port

    'user':"root", # username

    'password':"root@123", # password

    'db':"gupiao", # database

    'charset':'utf8mb4', # charset encoding
    'cursorclass':pymysql.cursors.DictCursor

    }

